import { local, session } from './storage'

let fetchData = (url, opts, callback) => {
	const webEndemicId = local.get('WEB-ENDEMIC-ID');
	const postHeader = webEndemicId == null ? {
		'Accept': 'application/json',
		'Content-Type': 'application/json',
		'WEB-ENDEMIC-ID': 137
	} : {
		'Accept': 'application/json',
		'Content-Type': 'application/json',
		'WEB-ENDEMIC-ID': webEndemicId
	}
	fetch(url, {
		headers: postHeader,
		method: 'post',
		mode: 'cors',
		credentials: 'include',
		body: JSON.stringify(opts)
	})
		.then(response => response.json())
		.then(res => {
			callback(res);
		})
}
export default fetchData;
